#include "GlobalHead.h"
#include "PartPathCamera.h"
#include "PrimitiveFeature.h"
#include "CustomPlayer.h"
using namespace Part;
using namespace App;
PROPERTY_SOURCE(Part::PartPathCamera, Part::Primitive)

PartPathCamera::PartPathCamera(void)
:pCamera(NULL)
{
   ADD_PROPERTY_TYPE(fov,(54.0),"CameraProp",Prop_None,"PathCamera field of view");
	ADD_PROPERTY_TYPE(nearClip,(1.0),"CameraProp",Prop_None,"PathCamera near clip");
	ADD_PROPERTY_TYPE(farClip,(4000.0),"CameraProp",Prop_None,"PathCamera far clip");
}

PartPathCamera::~PartPathCamera(void)
{
	 CCustomPlayer::Instance().DeleteObjectFromScene(this->Shape.getValue()/*->GetID()*/);
}

void PartPathCamera::onChanged(const App::Property* prop)
{
   
}
App::DocumentObjectExecReturn* PartPathCamera::execute()
{
   if(isImporting())
   {
	   std::string pName = getNameInDocument();
	  CK3dEntity* pCamParent = static_cast<CK3dEntity*>(CCustomPlayer::Instance().createSceneObject(CKCID_3DENTITY,(char*)pName.c_str()));
	  pName += "_cam";
	  CKCamera* pCam = static_cast<CKCamera*>(GetCKContext(0)->CreateObject(CKCID_CAMERA,(CKSTRING)pName.c_str()));
	  pCam->SetParent(pCamParent);
     this->Shape.setValue(pCamParent);
   }
	return App::DocumentObject::StdReturn;
}
short PartPathCamera::mustExecute()const
{
	return Part::Primitive::mustExecute();
}
// void PartPathCamera::Save (Base::Writer &writer)
// {
// 
// }
// 
// void PartPathCamera::Restore(Base::XMLReader &reader)
// {
// 
// }


